From a37c35450bbb8bb1901e617ae90192b666bfa36a Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sat, 24 Jan 2009 08:52:04 +0000 Subject: [PATCH] Do a complete overhaul of the babl API. * babl/babl.h: Instead of including subsystem headers, declare the functions part of the API directly in the header. The public types, macros and the version header is still pulled in as includes but with inclusion guards that prevent them from being included separately by clients. Notable things removed from the API is internal class functions and the class instance structs. (babl_format_has_alpha) (babl_format_get_bytes_per_pixel) (babl_format_get_num_of_components) (babl_format_get_type): New getters to allow the Babl union to become opaque for clients. * babl/babl-types.h: New file with public types. Currently only the opaque Babl union and the linear and planar conversion function prototypes (which are not used in the API due to the use of varags but still part of the API for reference) are there. Make sure it's only included indirectly through babl.h. * babl/babl-macros.h * babl/babl-version.h.in: Make sure these are not included directly, only indirectly through babl.h. * babl/babl-main.h: Removed, function declarations are in babl.h now. * babl/babl-internal.h: Include the headers we now consider internal, mostly the different class headers. * babl/babl-class.h: The "named class" function declarations are now in the public header so move them away from this internal header. * babl/babl-image.h * babl/babl-format.h * babl/babl-fish.h * babl/babl-extension.h * babl/babl-conversion.h * babl/babl-component.h * babl/babl-classes.h * babl/babl-introspect.h * babl/babl-sampling.h * babl/babl-model.h * babl/babl-type.h: Adapt to above changes, move relevant things to babl.h * babl/base/formats.c * babl/base/model-gray.c * babl/base/model-rgb.c * babl/base/model-ycbcr.c * babl/base/type-float.c: Explicitly #include "babl-classes.h". * babl/babl-internal.c: s/babl_name/babl_get_name/ * babl/babl-format.c (babl_format_has_alpha) (babl_format_get_bytes_per_pixel) (babl_format_get_num_of_components) (babl_format_get_type): Implement these. * babl/Makefile.am: Don't install the now internal headers and add, remove and install the other headers according to above changes. svn path=/trunk/; revision=390 --- ChangeLog | 67 +++++++++++++++ babl/Makefile.am | 20 +---- babl/babl-class.h | 30 +++---- babl/babl-classes.h | 5 +- babl/babl-component.h | 8 -- babl/babl-conversion.h | 27 +----- babl/babl-extension.h | 5 +- babl/babl-fish.h | 17 ---- babl/babl-format.c | 53 ++++++++++++ babl/babl-format.h | 24 ------ babl/babl-image.h | 3 - babl/babl-internal.c | 2 +- babl/babl-internal.h | 3 + babl/babl-introspect.h | 14 --- babl/babl-macros.h | 5 +- babl/babl-main.h | 46 ---------- babl/babl-model.h | 17 ---- babl/babl-sampling.h | 10 +-- babl/babl-type.h | 18 ---- babl/babl-types.h | 49 +++++++++++ babl/babl-version.h.in | 5 ++ babl/babl.h | 183 ++++++++++++++++++++++++++++++++++++---- babl/base/formats.c | 1 + babl/base/model-gray.c | 1 + babl/base/model-rgb.c | 1 + babl/base/model-ycbcr.c | 2 + babl/base/type-float.c | 1 + 27 files changed, 379 insertions(+), 238 deletions(-) create mode 100644 babl/babl-types.h diff --git a/ChangeLog b/ChangeLog index ac3293b..126762b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,70 @@ +2009-01-24 Martin Nordholts + + Do a complete overhaul of the babl API. + + * babl/babl.h: Instead of including subsystem headers, declare the + functions part of the API directly in the header. The public + types, macros and the version header is still pulled in as + includes but with inclusion guards that prevent them from being + included separately by clients. Notable things removed from the + API is internal class functions and the class instance structs. + + (babl_format_has_alpha) + (babl_format_get_bytes_per_pixel) + (babl_format_get_num_of_components) + (babl_format_get_type): New getters to allow the Babl union to + become opaque for clients. + + * babl/babl-types.h: New file with public types. Currently only + the opaque Babl union and the linear and planar conversion + function prototypes (which are not used in the API due to the use + of varags but still part of the API for reference) are there. Make + sure it's only included indirectly through babl.h. + + * babl/babl-macros.h + * babl/babl-version.h.in: Make sure these are not included + directly, only indirectly through babl.h. + + * babl/babl-main.h: Removed, function declarations are in babl.h + now. + + * babl/babl-internal.h: Include the headers we now consider + internal, mostly the different class headers. + + * babl/babl-class.h: The "named class" function declarations are + now in the public header so move them away from this internal + header. + + * babl/babl-image.h + * babl/babl-format.h + * babl/babl-fish.h + * babl/babl-extension.h + * babl/babl-conversion.h + * babl/babl-component.h + * babl/babl-classes.h + * babl/babl-introspect.h + * babl/babl-sampling.h + * babl/babl-model.h + * babl/babl-type.h: Adapt to above changes, move relevant things to babl.h + + * babl/base/formats.c + * babl/base/model-gray.c + * babl/base/model-rgb.c + * babl/base/model-ycbcr.c + * babl/base/type-float.c: Explicitly #include "babl-classes.h". + + * babl/babl-internal.c: s/babl_name/babl_get_name/ + + * babl/babl-format.c + (babl_format_has_alpha) + (babl_format_get_bytes_per_pixel) + (babl_format_get_num_of_components) + (babl_format_get_type): Implement these. + + * babl/Makefile.am: Don't install the now internal headers and + add, remove and install the other headers according to above + changes. + 2009-01-18 Martin Nordholts Since babl_foo_from_id() will not be part of the public API we can diff --git a/babl/Makefile.am b/babl/Makefile.am index 039e756..25932bd 100644 --- a/babl/Makefile.am +++ b/babl/Makefile.am @@ -41,8 +41,8 @@ h_sources = \ babl-internal.h \ babl-introspect.h \ babl-macros.h \ - babl-main.h \ babl-memory.h \ + babl-types.h \ babl-util.h \ babl.h \ babl-list.h \ @@ -51,22 +51,10 @@ h_sources = \ library_includedir=$(includedir)/babl-$(BABL_API_VERSION)/babl library_include_HEADERS = \ - babl.h \ - babl-class.h \ - babl-classes.h \ - babl-component.h \ - babl-conversion.h \ - babl-extension.h \ - babl-fish.h \ - babl-format.h \ - babl-image.h \ - babl-introspect.h \ babl-macros.h \ - babl-main.h \ - babl-model.h \ - babl-sampling.h \ - babl-type.h \ - babl-version.h + babl-types.h \ + babl-version.h \ + babl.h INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/babl/base diff --git a/babl/babl-class.h b/babl/babl-class.h index 4b995ad..534c476 100644 --- a/babl/babl-class.h +++ b/babl/babl-class.h @@ -19,13 +19,12 @@ #ifndef _BABL_CLASS_H #define _BABL_CLASS_H -#ifndef _BABL_H -#error this file is only to be included by babl.h -#endif +#include "babl.h" -typedef int BablClassType; -typedef union _Babl Babl; +typedef struct _BablList BablList; + +typedef int BablClassType; typedef int (*BablEachFunction) (Babl *entry, void *data); @@ -42,18 +41,17 @@ void babl_##klass##_class_destroy (void); \ void babl_##klass##_class_for_each (BablEachFunction each_fun, \ void *user_data) -/* creates a class that has a specific name connected to it, that - * also allows defining a new instance. These classes share common - * functionality with the non_name classes but have two extra methods, - * the means to lookup by name, as well as to create new named objects - * that later can be looked up. +/* If a class is declared as a "named class" it means it is a class + * that has a specific name connected to it, that also allows defining + * a new instance. These classes share common functionality with the + * non_name classes but have two extra methods, the means to lookup by + * name, as well as to create new named objects that later can be + * looked up. These methods are babl_klass() babl_klass_new() but they + * are declared outside of this macro. */ -#define BABL_NAMED_CLASS_DECLARE(klass) \ - \ -BABL_CLASS_DECLARE (klass); \ -Babl * babl_##klass (const char *name); \ -Babl * babl_##klass##_new (void *first_arg, \ - ...) BABL_ARG_NULL_TERMINATED +#define BABL_NAMED_CLASS_DECLARE(klass) \ +BABL_CLASS_DECLARE (klass) + /* common header for any item inserted into database, the actual * implementation of babl-instance is in babl-internal diff --git a/babl/babl-classes.h b/babl/babl-classes.h index 84b694c..eeaa262 100644 --- a/babl/babl-classes.h +++ b/babl/babl-classes.h @@ -19,10 +19,7 @@ #ifndef _BABL_CLASSES_H #define _BABL_CLASSES_H -#ifndef _BABL_H -#error this file is only to be included by babl.h -#endif - +#include "babl-class.h" /* magic number used at the start of all babl objects, used to do * differentiation in polymorphic functions. (as well as manual type diff --git a/babl/babl-component.h b/babl/babl-component.h index e7f7852..df9d719 100644 --- a/babl/babl-component.h +++ b/babl/babl-component.h @@ -19,18 +19,10 @@ #ifndef _BABL_COMPONENT_H #define _BABL_COMPONENT_H -#ifndef _BABL_H -#error this file is only to be included by babl.h -#endif - /****************************************************************/ /* BablComponent */ BABL_NAMED_CLASS_DECLARE (component); -/* - * Babl * babl_component_new (const char *name, - * NULL); - */ typedef struct diff --git a/babl/babl-conversion.h b/babl/babl-conversion.h index edfc8d2..d231b64 100644 --- a/babl/babl-conversion.h +++ b/babl/babl-conversion.h @@ -19,26 +19,11 @@ #ifndef _BABL_CONVERSION_H #define _BABL_CONVERSION_H -#ifndef _BABL_H -#error this file is only to be included by babl.h -#endif - -/****************************************************************/ -/* BablConversion */ BABL_NAMED_CLASS_DECLARE (conversion); -/* - * Babl * babl_conversion_new (, - * <"linear"|"planar">, BablConversionFunc conv_func, - * NULL); - */ + +Babl * babl_conversion (const char *name); -/* Type and Format */ -typedef long (*BablFuncLinear) (char *src, - char *dst, - long n); /* Signature of functions registered for reference type * conversions, @@ -49,14 +34,6 @@ typedef long (*BablFuncPlane) (char *src, int dst_pitch, long n); -/* TypePlanar,ModelPlanar and FormatPlanar */ -typedef long (*BablFuncPlanar) (int src_bands, - char *src[], - int src_pitch[], - int dst_bands, - char *dst[], - int dst_pitch[], - long n); typedef struct BablConversion { diff --git a/babl/babl-extension.h b/babl/babl-extension.h index 9652e24..cd7f831 100644 --- a/babl/babl-extension.h +++ b/babl/babl-extension.h @@ -19,9 +19,6 @@ #ifndef _BABL_EXTENSION_H #define _BABL_EXTENSION_H -#ifndef _BABL_H -#error this file is only to be included by babl.h -#endif /****************************************************************/ /* BablExtension */ @@ -30,6 +27,8 @@ BABL_NAMED_CLASS_DECLARE (extension); * BablExtension objects are only used internally in babl. */ +Babl * babl_extension (const char *name); + typedef struct { diff --git a/babl/babl-fish.h b/babl/babl-fish.h index b04a689..1592329 100644 --- a/babl/babl-fish.h +++ b/babl/babl-fish.h @@ -19,27 +19,10 @@ #ifndef _BABL_FISH_H #define _BABL_FISH_H -#ifndef _BABL_H -#error this file is only to be included by babl.h -#endif /****************************************************************/ /* BablFish */ BABL_CLASS_DECLARE (fish); -/* Create a babl fish capable of converting from source_format to - * destination_format, source and destination can be - * either strings with the names of the formats or BablFormat objects. - */ -Babl * babl_fish (const void *source_format, - const void *destination_format); - -/** Process n pixels from source to destination using babl_fish, - * returns number of pixels converted. - */ -long babl_process (Babl *babl_fish, - void *source, - void *destination, - long n); /* BablFish, common base class for various fishes. */ diff --git a/babl/babl-format.c b/babl/babl-format.c index f72143a..45dfa05 100644 --- a/babl/babl-format.c +++ b/babl/babl-format.c @@ -328,6 +328,59 @@ babl_formats_count (void) return babl_db_count (db); } +int +babl_format_has_alpha (const Babl *format) +{ + int i; + int has_alpha = 0; + + for (i = 0; i < babl_format_get_num_of_components (format); i++) + { + if (format->format.component[i]->alpha) + { + has_alpha = 1; + break; + } + } + + return has_alpha; +} + +int +babl_format_get_bytes_per_pixel (const Babl *format) +{ + if (format->class_type == BABL_FORMAT) + { + return format->format.bytes_per_pixel; + } + + return 0; +} + +int +babl_format_get_num_of_components (const Babl *format) +{ + if (format->class_type == BABL_FORMAT) + { + return format->format.components; + } + + return 0; +} + +Babl * +babl_format_get_type (const Babl *format, + int component_index) +{ + if (format->class_type == BABL_FORMAT && + component_index >= 0 && + component_index < format->format.components) + { + return (Babl *)format->format.type[component_index]; + } + + return NULL; +} Babl * babl_format_with_model_as_type (Babl *model, diff --git a/babl/babl-format.h b/babl/babl-format.h index 1e1de1f..f130bcd 100644 --- a/babl/babl-format.h +++ b/babl/babl-format.h @@ -19,31 +19,7 @@ #ifndef _BABL_FORMAT_H #define _BABL_FORMAT_H -#ifndef _BABL_H -#error this file is only to be included by babl.h -#endif - -/****************************************************************/ -/* BablFormat */ BABL_NAMED_CLASS_DECLARE (format); -/* - * Babl * babl_format_new (["name", const char *name,] - * BablModel *model, - * [BablType *type,] - * [BablSampling, *sampling,] - * BablComponent *component1, - * [[BablType *type,] - * [BablSampling *sampling,] - * BablComponent *componentN, - * ...] - * ["planar",] - * NULL); - * - * Provided BablType and|or BablSampling is valid for the following - * components as well. If no name is provided a (long) descriptive - * name is used. - */ - typedef struct { diff --git a/babl/babl-image.h b/babl/babl-image.h index ca2787a..2b7a2a8 100644 --- a/babl/babl-image.h +++ b/babl/babl-image.h @@ -19,9 +19,6 @@ #ifndef _BABL_IMAGE_H #define _BABL_IMAGE_H -#ifndef _BABL_H -#error this file is only to be included by babl.h -#endif /****************************************************************/ /* BablImage */ diff --git a/babl/babl-internal.c b/babl/babl-internal.c index 8de4ce5..8fd7fba 100644 --- a/babl/babl-internal.c +++ b/babl/babl-internal.c @@ -132,7 +132,7 @@ babl_internal_destroy (void) const char * -babl_name (const Babl *babl) +babl_get_name (const Babl *babl) { babl_assert (BABL_IS_BABL (babl)); return babl->instance.name; diff --git a/babl/babl-internal.h b/babl/babl-internal.h index 6024d87..7baf910 100644 --- a/babl/babl-internal.h +++ b/babl/babl-internal.h @@ -38,6 +38,9 @@ #include "config.h" +#include "babl-class.h" +#include "babl-classes.h" +#include "babl-introspect.h" #include "babl-list.h" #include "babl-hash-table.h" #include "babl-db.h" diff --git a/babl/babl-introspect.h b/babl/babl-introspect.h index 6b6d95d..6e32a2a 100644 --- a/babl/babl-introspect.h +++ b/babl/babl-introspect.h @@ -19,20 +19,6 @@ #ifndef _BABL_INTROSPECT_H #define _BABL_INTROSPECT_H -#ifndef _BABL_H -#error this file is only to be included by babl.h -#endif - - -/** - * babl_name: - * - * Return a string decsribing a BablInstance, might work better than - * babl->instance.name when a good human readable name is desired. - * - * Returns: a name describing the instance. - */ -const char * babl_name (const Babl *babl); void babl_introspect (Babl *babl); /* introspect a given BablObject */ diff --git a/babl/babl-macros.h b/babl/babl-macros.h index 7eae084..8de6864 100644 --- a/babl/babl-macros.h +++ b/babl/babl-macros.h @@ -19,10 +19,11 @@ #ifndef _BABL_MACROS_H #define _BABL_MACROS_H -#ifndef _BABL_H -#error this file is only to be included by babl.h +#ifndef BABL_INSIDE_BABL_H +#error "babl-version.h must not be included directly, include babl.h instead." #endif + #if __GNUC__ >= 4 #define BABL_ARG_NULL_TERMINATED __attribute__((__sentinel__)) #else diff --git a/babl/babl-main.h b/babl/babl-main.h index 8cfafa5..e69de29 100644 --- a/babl/babl-main.h +++ b/babl/babl-main.h @@ -1,46 +0,0 @@ -/* babl - dynamically extendable universal pixel conversion library. - * Copyright (C) 2005-2008, Øyvind Kolås and others. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see - * . - */ - -#ifndef _BABL_MAIN_H -#define _BABL_MAIN_H - -#ifndef _BABL_H -#error this file is only to be included by babl.h -#endif - -/** - * Initialize the babl library - */ -void babl_init (void); - -/** - * Deinitialize the babl library (frees any resources used, if the - * number of calls to babl_exit() is is equal to the number of calls - * to babl_init() - */ -void babl_exit (void); - - -#ifndef BABL_DISABLE_DEPRECATED - -#define babl_destroy babl_exit - -#endif /* BABL_DISABLE_DEPRECATED */ - - -#endif diff --git a/babl/babl-model.h b/babl/babl-model.h index 7b8a54c..617c91c 100644 --- a/babl/babl-model.h +++ b/babl/babl-model.h @@ -19,24 +19,7 @@ #ifndef _BABL_MODEL_H #define _BABL_MODEL_H -#ifndef _BABL_H -#error this file is only to be included by babl.h -#endif - -/****************************************************************/ -/* BablModel */ BABL_NAMED_CLASS_DECLARE (model); -/* - * Babl * babl_model_new (["name", const char *name,] - * BablComponent *component1, - * [BablComponent *componentN, ...] - * NULL); - * - * If no name is provided a name is generated by concatenating the - * name of all the involved components. - * - */ - typedef struct { diff --git a/babl/babl-sampling.h b/babl/babl-sampling.h index 319d80d..869e3de 100644 --- a/babl/babl-sampling.h +++ b/babl/babl-sampling.h @@ -19,16 +19,8 @@ #ifndef _BABL_SAMPLING_H #define _BABL_SAMPLING_H -#ifndef _BABL_H -#error this file is only to be included by babl.h -#endif - -/****************************************************************/ -/* BablSampling */ BABL_CLASS_DECLARE (sampling); -/**/ -Babl * babl_sampling (int horizontal, - int vertical); + typedef struct { BablInstance instance; diff --git a/babl/babl-type.h b/babl/babl-type.h index 581317c..10e4040 100644 --- a/babl/babl-type.h +++ b/babl/babl-type.h @@ -19,25 +19,7 @@ #ifndef _BABL_TYPE_H #define _BABL_TYPE_H -#ifndef _BABL_H -#error this file is only to be included by babl.h -#endif - -/****************************************************************/ -/* BablType */ BABL_NAMED_CLASS_DECLARE (type); -/* - * A data type that babl can have in it's buffers, requires - * conversions to and from "double" to be registered before - * passing sanity. - * - * Babl * babl_type_new ( const char *name, - * "bits", int bits, - * ["min_val", double min_val,] - * ["max_val", double max_val,] - * NULL); - */ - typedef struct { diff --git a/babl/babl-types.h b/babl/babl-types.h new file mode 100644 index 0000000..d1deae7 --- /dev/null +++ b/babl/babl-types.h @@ -0,0 +1,49 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2005-2008, Øyvind Kolås and others. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * . + */ + +#ifndef _BABL_TYPES_H +#define _BABL_TYPES_H + +#ifndef BABL_INSIDE_BABL_H +#error "babl-version.h must not be included directly, include babl.h instead." +#endif + + +/** + * The babl API is based around polymorphism and almost everything is + * a Babl object. + */ +typedef union _Babl Babl; + +/* Conversion function between linear data of a either a data types or + * color formats. + */ +typedef long (*BablFuncLinear) (char *src, + char *dst, + long n); + +/* TypePlanar,ModelPlanar and FormatPlanar */ +typedef long (*BablFuncPlanar) (int src_bands, + char *src[], + int src_pitch[], + int dst_bands, + char *dst[], + int dst_pitch[], + long n); + +#endif diff --git a/babl/babl-version.h.in b/babl/babl-version.h.in index 40d3930..9789099 100644 --- a/babl/babl-version.h.in +++ b/babl/babl-version.h.in @@ -19,6 +19,11 @@ #ifndef _BABL_VERSION_H #define _BABL_VERSION_H +#ifndef BABL_INSIDE_BABL_H +#error "babl-version.h must not be included directly, include babl.h instead." +#endif + + /*** * babl version information * diff --git a/babl/babl.h b/babl/babl.h index f953c1c..bd53839 100644 --- a/babl/babl.h +++ b/babl/babl.h @@ -16,27 +16,180 @@ * . */ -/* NOTE! the babl API is polymorphic, it is probably easier to learn - * it's usage by studying examples than this header file. The public - * functions are attempted explained anyways. - */ - #ifndef _BABL_H #define _BABL_H -#ifdef _BABL_INTERNAL_H -#error babl.h included after babl-internal.h -#endif +#define BABL_INSIDE_BABL_H +#include "babl-version.h" +#include "babl-macros.h" +#include "babl-types.h" +#undef BABL_INSIDE_BABL_H -typedef struct _BablList BablList; +/** + * Initializes the babl library. + */ +void babl_init (void); -#include "babl-macros.h" -#include "babl-main.h" -#include "babl-class.h" -#include "babl-introspect.h" -#include "babl-version.h" -#include "babl-classes.h" +/** + * Deinitializes the babl library and frees any resources used when + * matched with the number of calls to babl_init(). + */ +void babl_exit (void); + +/** + * Returns the babl object representing the data type given by @name + * such as for example "u8", "u16" or "float". + */ +Babl * babl_type (const char *name); + +/** + * Returns the babl object representing the @horizontal and @vertical + * sampling such as for example 2, 2 for the chroma components in + * YCbCr. + */ +Babl * babl_sampling (int horizontal, + int vertical); + +/** + * Returns the babl object representing the color component given by + * @name such as for example "R", "cyan" or "CIE L". + */ +Babl * babl_component (const char *name); + +/** + * Returns the babl object representing the color model given by @name + * such as for example "RGB", "CMYK" or "CIE Lab". + */ +Babl * babl_model (const char *name); + +/** + * Returns the babl object representing the color format given by + * @name such as for example "RGB u8", "CMYK float" or "CIE Lab u16". + */ +Babl * babl_format (const char *name); + +/* Create a babl fish capable of converting from source_format to + * destination_format, source and destination can be either strings + * with the names of the formats or Babl-format objects. + */ +Babl * babl_fish (const void *source_format, + const void *destination_format); + +/** Process n pixels from source to destination using babl_fish, + * returns number of pixels converted. + */ +long babl_process (Babl *babl_fish, + void *source, + void *destination, + long n); + + +/** + * Returns a string decsribing a Babl object. + */ +const char * babl_get_name (const Babl *babl); + +/** + * Returns whether the @format has an alpha channel. + */ +int babl_format_has_alpha (const Babl *format); + +/** + * Returns the bytes per pixel for a babl color format. + */ +int babl_format_get_bytes_per_pixel (const Babl *format); + +/** + * Returns the number of components for the given @format. + */ +int babl_format_get_num_of_components (const Babl *format); + +/** + * Returns the type in the given @format for the given + * @component_index. + */ +Babl * babl_format_get_type (const Babl *format, + int component_index); + + +/** + * Defines a new data type in babl. A data type that babl can have in + * its buffers requires conversions to and from "double" to be + * registered before passing sanity. + * + * babl_type_new (const char *name, + * "bits", int bits, + * ["min_val", double min_val,] + * ["max_val", double max_val,] + * NULL); + */ +Babl * babl_type_new (void *first_arg, + ...) BABL_ARG_NULL_TERMINATED; + +/** + * Defines a new color component with babl. + * + * babl_component_new (const char *name, + * NULL); + */ +Babl * babl_component_new (void *first_arg, + ...) BABL_ARG_NULL_TERMINATED; + +/** + * Defines a new color model in babl. If no name is provided a name is + * generated by concatenating the name of all the involved components. + * + * babl_model_new (["name", const char *name,] + * BablComponent *component1, + * [BablComponent *componentN, ...] + * NULL); + */ +Babl * babl_model_new (void *first_arg, + ...) BABL_ARG_NULL_TERMINATED; + +/** + * Defines a new color format in babl. Provided BablType and|or + * BablSampling is valid for the following components as well. If no + * name is provided a (long) descriptive name is used. + * + * babl_format_new (["name", const char *name,] + * BablModel *model, + * [BablType *type,] + * [BablSampling, *sampling,] + * BablComponent *component1, + * [[BablType *type,] + * [BablSampling *sampling,] + * BablComponent *componentN, + * ...] + * ["planar",] + * NULL); + */ +Babl * babl_format_new (void *first_arg, + ...) BABL_ARG_NULL_TERMINATED; + +/** + * Defines a new conversion between either two formats, two models or + * two types in babl. + * + * babl_conversion_new (, + * <"linear"|"planar">, conv_func, + * NULL); + */ +Babl * babl_conversion_new (void *first_arg, + ...) BABL_ARG_NULL_TERMINATED; + + +/* + * Backwards compatibility stuff + * + * NOTE: will most likely be removed in the first stable release! + */ +#ifndef BABL_DISABLE_DEPRECATED +#define babl_destroy babl_exit +#endif #endif diff --git a/babl/base/formats.c b/babl/base/formats.c index a72d9f3..212b86a 100644 --- a/babl/base/formats.c +++ b/babl/base/formats.c @@ -18,6 +18,7 @@ #include +#include "babl-classes.h" #include "babl.h" #include "babl-ids.h" #include "babl-base.h" diff --git a/babl/base/model-gray.c b/babl/base/model-gray.c index 1684879..f46eb59 100644 --- a/babl/base/model-gray.c +++ b/babl/base/model-gray.c @@ -18,6 +18,7 @@ #include +#include "babl-classes.h" #include "babl.h" #include "babl-ids.h" #include "util.h" diff --git a/babl/base/model-rgb.c b/babl/base/model-rgb.c index 4edbea7..da772c7 100644 --- a/babl/base/model-rgb.c +++ b/babl/base/model-rgb.c @@ -20,6 +20,7 @@ #include #include "babl.h" +#include "babl-classes.h" #include "babl-ids.h" #include "util.h" #include "babl-base.h" diff --git a/babl/base/model-ycbcr.c b/babl/base/model-ycbcr.c index ba3d706..dc766ec 100644 --- a/babl/base/model-ycbcr.c +++ b/babl/base/model-ycbcr.c @@ -19,7 +19,9 @@ #include #include #include + #include "babl.h" +#include "babl-classes.h" #include "babl-ids.h" #include "babl-base.h" diff --git a/babl/base/type-float.c b/babl/base/type-float.c index c358b16..b8f7620 100644 --- a/babl/base/type-float.c +++ b/babl/base/type-float.c @@ -20,6 +20,7 @@ #include #include "babl.h" +#include "babl-classes.h" #include "babl-ids.h" #include "babl-base.h" -- 2.30.2